Example: The following example will display a custom rectangle on the page with autogradient pattern.
import com.cete.dynamicpdf.*; import com.cete.dynamicpdf.pageelements.*; public class MyClass{ public static void main(String args[]){ // Create a PDF Document Document document = new Document(); // Create a Page and add it to the document Page page = new Page(); document.getPages().add(page); // Create a rectangle Rectangle rectangle = new Rectangle( 50, 50, 200, 200,Grayscale.getBlack(), RgbColor.getGray(), 4, LineStyle.getSolid() ); // Change the corner radius property rectangle.setCornerRadius(10); // Create a autogradient AutoGradient autogradient = new AutoGradient(90f, CmykColor.getBlue(), CmykColor.getRed()); // Set autogradient to Fillcolor property of rectangle rectangle.setFillColor(autogradient); // Add the rectangle to the page page.getElements().add(rectangle); // Save the PDF document.draw("[PhysicalPath]/MyDocument.pdf" ); } }